package com.zk.mockito.cases;

import org.junit.Test;

import java.util.List;

import static org.mockito.Mockito.*;

public class Case008_FindingRedundantInvocations {
    /**
     * 举例而言：当记录两个存根，而仅仅verify一个时，调用verifyNoMoreInteractions会发生存根异常，
     * 必须如下所示，全部调用全部被验证后，才能保证verifyNoMoreInteractions返回正确结果。
     */
    @Test
    public void testVerifyNoMoreInteractions() {

        List mockedList = mock(List.class);

        //using mocks
        mockedList.add("one");
        mockedList.add("two");

        verify(mockedList).add("one");
        verify(mockedList).add("two");

        //following verification will fail
        verifyNoMoreInteractions(mockedList);

    }

}
